<?php 
class MySQLQueries {


	function MySQLQueries() {
		return TRUE;
	}

	function systemSettingsSQL() {

		$SQL = "SELECT * \n"
			 . "  FROM systemsettings \n";
		return $SQL;
	}

	function clientsSQL($where=NULL, $limit=NULL, $row=NULL) {
		$SQL = "SELECT CONCAT(IF(BusinessName IS NULL, '', CONCAT(BusinessName, ', ')), \n"
			  ."              IF(Address IS NULL, '', CONCAT(Address, ', ')),  \n"
			  ."              IF(Address2 IS NULL, '', CONCAT(Address2, ', ')),  \n"
			  ."              IF(Country IS NULL, '', CONCAT(Country, ', ')),  \n"
			  ."              IF(City IS NULL, '', CONCAT(City, ', ')),  \n"
			  ."              IF(PostCode IS NULL, '', CONCAT(PostCode, ''))) AS BillTo, id, BusinessName, Address, Address2, Country, City, PostCode  \n"
			  ."  FROM clients \n";

		return $SQL;
	}

	function itemCatSQL() {

		$SQL = "SELECT * \n"
			 . "  FROM itemcategory \n"
			 . " ORDER BY Name \n";
		return $SQL;
	}

	function productsList() {

		$SQL = "SELECT i.*, ic.Name AS CategoryName, ic.id AS CategoryID\n"
			  ."  FROM items i \n"
			  ."       LEFT JOIN item_itemcategory iic ON i.id = iic.ItemID\n"
			  ."       LEFT JOIN itemcategory ic ON ic.id = iic.ItemCategoryID\n"
			  ." ORDER BY CategoryName, i.Name\n";

		return $SQL;
	}
}

?>
